/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package com.inspur.edp.lcm.metadata.spi;

import com.inspur.edp.lcm.metadata.api.entity.GspMetadata;
import com.inspur.edp.lcm.metadata.spi.entity.MetadataElement;
import com.inspur.edp.lcm.metadata.spi.entity.MetadataElementDependencyDetail;
import com.inspur.edp.lcm.metadata.spi.entity.ValidateResult;
import io.iec.edp.caf.multicontext.annotation.Collect;

/**
 * 元数据内容节点校验规则SPI接口类
 *
 * @author sunhongfei
 */
@Collect
public interface MetadataElementValidator {
    /**
     * 当前校验规则实现类适配的引用类型<p>
     * 应与元数据依赖详情中记录的引用类型一致{@link MetadataElementDependencyDetail#getReferenceType()}
     * @return 当前校验规则实现类适配的校验类型
     */
    String getReferenceType();

    /**
     * 根据当前元数据、当前元数据内容节点、引用元数据、引用元数据内容节点进行校验。
     * 并返回校验结果
     * @param sourceElement 当前元数据内容节点
     * @param targetElement 引用元数据内容节点
     * @param sourceMetadata 当前元数据
     * @param targetMetadata 引用元数据
     * @return 校验结果
     */
    ValidateResult validate(MetadataElement sourceElement, MetadataElement targetElement, GspMetadata sourceMetadata, GspMetadata targetMetadata);

}
